home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 10
/
AACD 10.iso
/
AACD
/
Utilities
/
GOCR
/
gocr.tcl
< prev
next >
Wrap
Text File
|
2000-05-29
|
5KB
|
169 lines
# menu frame
# image gif ppm pgm
frame .mbar -borderwidth 1 -relief raised
pack .mbar -fill x
menubutton .mbar.file -text "File" -menu .mbar.file.m
pack .mbar.file -side left
menu .mbar.file.m
.mbar.file.m add command -label "Exit" -command exit
set spacewidth 0
set graylevel 160
set dustsize 20
set file "text.pbm"
menubutton .mbar.options -text "Options" -menu .mbar.options.m
pack .mbar.options -side left
menu .mbar.options.m
.mbar.options.m add command -label "set spacewidth ($spacewidth)"
.mbar.options.m add command -label "set graylevel ($graylevel)"
.mbar.options.m add command -label "set dustsize ($dustsize)"
.mbar.options.m add cascade -menu .mbar.options.m.verbose -label "Verbose"
.mbar.options.m add cascade -menu .mbar.options.m.mode -label "Mode"
.mbar.options.m add command -label "Save options"
menu .mbar.options.m.mode
set m .mbar.options.m.mode
set m3 0
set m4 0
set m5 0
$m add check -label "use database" -variable m1 -onvalue 2 -offvalue 0
$m add check -label "layout analysis" -variable m2 -onvalue 4 -offvalue 0
$m add check -label "compare _ mode" -variable m3 -onvalue 0 -offvalue 8
$m add check -label "divide _ mode" -variable m4 -onvalue 0 -offvalue 16
$m add check -label "context correction" -variable m5 -onvalue 0 -offvalue 32
$m add check -label "char packing" -variable m6 -onvalue 64 -offvalue 0
menu .mbar.options.m.verbose
set m .mbar.options.m.verbose
$m add check -label "more info" -variable v0 -onvalue 1 -offvalue 0
$m add check -label "list chapes" -variable v1 -onvalue 2 -offvalue 0
$m add check -label "list pattern" -variable v2 -onvalue 4 -offvalue 0
$m add check -label "list all pattern" -variable v3 -onvalue 8 -offvalue 0
$m add check -label "line infos" -variable v4 -onvalue 16 -offvalue 0
$m add check -label "debug mode" -variable v5 -onvalue 32 -offvalue 0
menubutton .mbar.help -text "Help" -menu .mbar.help.m
pack .mbar.help -side right
menu .mbar.help.m
.mbar.help.m add command -label "About" -command aboutBox
# .mbar.help.m add command -label "Version"
# --------------------- action frame -----------------------
frame .abar -borderwidth 1 -relief sunken
pack .abar -fill x
set but [button .abar.go -text "Run it" -command Run]
#button .abar.go -text "Run it" -command { Run }
pack .abar.go -side left
label .abar.labf -text "File:"
entry .abar.entf -width 20
pack .abar.labf -side left
pack .abar.entf -side left
.abar.entf insert 0 $file
label .abar.status -text "ready"
pack .abar.status -side right
# ------------------ canvas, text ? -----------------
#canvas .pad -background white
#pack .pad
frame .t
#text .t
#pack .t
##.t insert end "history:"
##.t configure -state disabled
set log [text .t.log -width 80 -height 10 \
-borderwidth 2 -relief raised -setgrid true\
-yscrollcommand {.t.scroll set}]
scrollbar .t.scroll -command {.t.log yview}
pack .t.scroll -side right -fill y
pack .t.log -side left -fill both -expand true
pack .t -side top -fill both -expand true
bind .abar.entf <Return> Run
bind .abar.entf <Control-c> Stop
focus .abar.entf
tk_messageBox -icon info -type ok -title "Info" -message \
"This program is in development!\nUse carefully!\n"
# --------------------- run ---------------------
proc Run {} {
global fid but log file v0 v1 v2 v3 v4 m1 m2 m3 m4 m5 m6 spacewidth graylevel dustsize
.abar.status configure -text "progress"
# .abar.go configure -state disabled
update
set file [.abar.entf get]
set vvv [expr $v0 + $v1 + $v2 + $v3 + $v4 ]
set mode [expr $m1 + $m2 + $m3 + $m4 + $m5 + $m6 ]
set run "gocr -i $file -v $vvv -m $mode -s $spacewidth -l $graylevel -d $dustsize"
# puts $run
# .t configure -state normal
# .t insert end "\n$run"
# .t configure -state disabled
# update
# after 1000
# exec $run
# -- or --
# set fid [ open "| $run" "r" ]
if [catch {open "| $run |& cat" } fid] {
$log insert end $fid\n
} else {
fileevent $fid readable Log
$log insert end $run\n
$but config -text "Stop !" -command Stop
}
## gets $fid ; # ead headerline
# fileevent $fid readable "get_samples $fid"
}
proc Log {} {
global fid log
if [eof $fid] { Stop } else {
gets $fid line
$log insert end $line\n
$log see end
}
}
proc Stop {} {
global fid but
catch {close $fid}
$but config -text "Run it" -command Run
.abar.status configure -text "ready"
update
}
#proc get_samples {fid} {
# if {[gets $fid line] >= 0} {
## puts "$line"
## .t configure -state normal
# .t insert end "$line\n"
## .t configure -state disabled
# update
# } else {
# close $fid
# .abar.status configure -text "ready"
# .abar.go configure -state normal
# update
# }
#}
# aboutBox --
#
# Pops up a message box with an "about" message
#
proc aboutBox {} {
tk_messageBox -icon info -type ok -title "About" -message \
"Tcl/Tk Front End\n to GOCR v0.2\n\n v0.1 (c) 2000 JS"
}